<template>
  <div class="sidebar">

    <el-menu
      class="sidebar-el-menu"
      :default-active="onRoutes"
      :collapse="collapse"
      background-color="darkgray"
      text-color="#ffffff"
      active-text-color="#30a4fc"
      router>
      <el-menu-item index="infor">
        <i class="el-icon-house"></i>
        <span>系统首页</span>
      </el-menu-item>
      <el-menu-item index="consumer">
        <i class="el-icon-user-solid"></i>
        <span>用户管理</span>
      </el-menu-item>
      <el-menu-item index="staffList">
        <i class="el-icon-s-help"></i>
        <span>乐谱集管理</span>
      </el-menu-item>
      <el-menu-item index="approval">
        <i class="el-icon-bell"></i>
        <span>审批管理</span>
      </el-menu-item>

    </el-menu>
  </div>
</template>



<script>
import bus from "../assets/js/bus"
export default {
  name: "TheAside",
  data(){
    return{
      collapse: false,
    }
  },
  computed:{
    onRoutes(){
      return this.$route.path.replace('/','');
    }
  },
  created(){
    //通过Bus进行组件间的通信，来折叠侧边栏
    bus.$on('collapse',msg =>{
      this.collapse = msg
    })
  }

}
</script>
<style scoped>
.sidebar {
  display: block;
  position: absolute;
  left: 0;
  top: 70px;
  bottom: 0;
  background-color: darkgray;
  color: black;
  overflow-y: scroll;
}

.sidebar::-webkit-scrollbar{
  width: 0;
}

.sidebar-el-menu:not(.el-menu--collapse){
  width: 150px;
}

.sidebar >ul {
  height: 100%;
}
</style>


